<?php
if (!defined('BASEPATH')) {
	exit('No direct script access allowed');
}

class Feedback1_setting extends CI_Controller {

	function __construct() {
		parent::__construct();

		//jika digunakan di mayoritas function, panggil disini
		//model
		$this->load->model('m_feedback1_setting');

		//library breadcrum/untuk navigasi
		$this->load->library(array('breadcrumb','form_validation'));
		$this->load->helper(array('slug','id_date'));
	}

	function index() {

		//rule type pada function ini: Read
		$this->rule->type('R');

		//Layout
		//title
		$this->layout->set_title('Verifikasi Feedback 1');

		//meta description jika perlu
		$this->layout->set_desc('Made with love by Raksa Abadi Informatika');

		//css tambahan bila perlu
		$this->layout->set_include('css', 'themes/back/css/datatables/dataTables.bootstrap.css');
		$this->layout->set_include('js', 'themes/back/bundle/datepicker/jquery-ui.js');
		$this->layout->set_include('js', 'themes/back/bundle/datepicker/datepicker-id.js');
		$this->layout->set_include('css', 'themes/back/bundle/datepicker/datepicker.css');
		//js tambahan
		$this->layout->set_include('js', 'themes/general/bundle/jquery_validation/jquery.validate.min.js', 'header');
		$this->layout->set_include('js', 'themes/general/bundle/jquery_validation/localization/messages_id.min.js', 'header');

		//breadcrumb/untuk navigasi
		$this->breadcrumb->clear();
		$this->breadcrumb->add_crumb('Beranda', site_url());
		$this->breadcrumb->add_crumb('Verifikasi Feedback 1');	
		$this->breadcrumb->add_crumb('Setting');			

    //judul besar
		$data['primary_title'] 			= '<i class="ion-android-note"></i> Verifikasi Feedback 1';
		$data['sub_primary_title'] 	= '';
		$data['ppk']								= $this->m_feedback1_setting->getPPK();

		//menggunakan theme back
		$this->layout->theme('back','feedback1_setting/index', $data);
	}

	function save() {
		//rule type pada function ini: Create
		$this->rule->type('R');
		if($this->input->post('ppk') != ''){
			//mendaftarkan session
			$this->session->set_userdata('tgl_awal',$this->input->post('tgl_awal'));
			$this->session->set_userdata('tgl_akhir',$this->input->post('tgl_akhir'));
			$this->session->set_userdata('ppk', $this->input->post('ppk'));
			$this->session->set_flashdata('sukses', 'Setting berhasil, silahkan mulai verifikasi.');
			redirect('feedback1_setting','refresh');
		}else{
			$this->session->set_flashdata('gagal', 'Setting gagal, silahkan ulangi lagi.');
			redirect('feedback1_setting','refresh');
		}

		redirect('feedback1_setting');
	}
}
